<?php


namespace app\system\service;

class ConfigService
{
	public static function get_home_template_config_data($assignTemplate = "")
	{
		$home_config = \app\common\server\ConfigServer::get("website", "template_config");
		return get_template_config_data("./home/", $home_config, "config.json", $assignTemplate);
	}
	public static function clear_home_config($options)
	{
		\think\Db::startTrans();
		try {
			$template = self::get_home_template_config_data($options["template"]);
			$home_config = \app\common\server\ConfigServer::get("website", "template_config");
			if (is_array($home_config)) {
				unset($home_config["config"][$template["template"]]);
			}
			\think\Db::name("system_config")->where(["type" => "website", "name" => "template_config"])->delete();
			\think\Db::commit();
			return ["code" => \app\system\model\Code::success];
		} catch (\Exception $e) {
			\think\Db::rollback();
			return ["code" => \app\system\model\Code::error, "msg" => $e->getMessage()];
		}
	}
}